﻿using System.Drawing;
using Tank90.Properties;

namespace Tank90
{
    public class Map : Element
    {
        private MapElemenType _elemenType;
        public int ID { get; set; }

        public MapElemenType elemenType
        {
            get { return _elemenType; }
            set
            {
                _elemenType = value;
                MapTypeSetImage(value);
            }
        }

        private string type { get; set; }

        public string Type
        {
            get { return type; }
            set
            {
                type = value;
                set_Transparent(type);
            }
        }


        public int Transparent { get; set; }

        public override void Drawing(Graphics graphics)
        {
            if (dirImage != null)
            {
                graphics.DrawImage(dirImage, new Point(x, y));
            }
        }

        private void MapTypeSetImage(MapElemenType value)
        {
            switch (value)
            {
                    //case MapElemenType.FStone:
                    //    dirImage = Resources.fStone;
                    //    break;
                    //case MapElemenType.UStone:
                    //    dirImage = Resources.vUStone;
                    //    break;
                    //case MapElemenType.DStone:
                    //    dirImage = Resources.vDStone;
                    //    break;
                    //case MapElemenType.LStone:
                    //    dirImage = Resources.hLTStone;
                    //    break;
                    //case MapElemenType.RStone:
                    //    dirImage = Resources.hRTStone;
                    //    break;
                case MapElemenType.OStone:
                    dirImage = Resources.oStone;
                    break;


                    //case MapElemenType.FBrick:
                    //    dirImage = Resources.fBrick;
                    //    break;
                    //case MapElemenType.UBrick:
                    //    dirImage = Resources.vUBrick;
                    //    break;
                    //case MapElemenType.DBrick:
                    //    dirImage = Resources.vDBrick;
                    //    break;
                    //case MapElemenType.LBrick:
                    //    dirImage = Resources.hLBrick;
                    //    break;
                    //case MapElemenType.RBrick:
                    //    dirImage = Resources.hRBrick;
                    //    break;
                case MapElemenType.OBrick:
                    dirImage = Resources.oBrick;
                    break;

                case MapElemenType.Water:
                    dirImage = Resources.oWater;
                    break;
                case MapElemenType.Grass:
                    dirImage = Resources.oGrass;
                    break;
                case MapElemenType.White:
                    dirImage = Resources.oWhite;
                    break;
                default:
                    dirImage = null;
                    break;
            }
        }

        public void RemoveElement()
        {
        }

        private void set_Transparent(string type)
        {
            switch (type.ToLower())
            {
                case "ostone":
                    Transparent = 5;
                    elemenType = MapElemenType.OStone;
                    //  dirImage = Resources.oStone;
                    break;
                case "obrick":
                    Transparent = 4;
                    elemenType = MapElemenType.OBrick;
                    //  dirImage = Resources.oBrick;
                    break;
                case "water":
                    Transparent = 3;
                    elemenType = MapElemenType.Water;
                    //     dirImage = Resources.oWater;
                    break;
                case "grass":
                    Transparent = 2;
                    elemenType = MapElemenType.Grass;
                    //      dirImage=Resources.oGrass;
                    break;
                case "white":
                    Transparent = 1;
                    elemenType = MapElemenType.White;
                    //       dirImage = Resources.oWhite;
                    break;
                default:
                    elemenType = MapElemenType.None;
                    Transparent = 0;
                    //   dirImage = null;
                    break;
            }
        }

        public override Rectangle GetRectangle()
        {
            if (elemenType.Equals(MapElemenType.None))
            {
                return new Rectangle(1000, 1000, 0, 0);
            }
            return new Rectangle(x, y, 20, 20);
        }

        public override void Death()
        {
            base.Death();
            elemenType = MapElemenType.None;
        }
    }
}